/*
 * Wazuh Vulnerability Scanner - Unit Tests
 * Copyright (C) 2015, Wazuh Inc.
 * September 21, 2023.
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation.
 */

#include "vulnerabilityScannerFacade_test.hpp"
#include "vulnerabilityScannerFacade.hpp"
#include <external/nlohmann/json.hpp>
#include <memory>

auto constexpr DELAY {1};

/*
 * @brief Log function used by VulnerabilityScannerFacade.
 */
// LCOV_EXCL_START
void logFunction(const int logLevel,
                 const std::string& tag,
                 const std::string& file,
                 const int line,
                 const std::string& func,
                 const std::string& logMessage,
                 va_list args)
{
    std::ignore = logLevel;
    std::ignore = logMessage;
}
// LCOV_EXCL_STOP

/*
 * @brief Test singleton of the VulnerabilityScannerFacade class.
 */
TEST_F(VulnerabilityScannerFacadeTest, TestSingletonOfTheVulnerabilityScannerFacadeClass)
{
    auto& vulnerabilityScannerFacade {VulnerabilityScannerFacade::instance()};

    EXPECT_EQ(&vulnerabilityScannerFacade, &VulnerabilityScannerFacade::instance());
}

/*
 * @brief Test start method of the VulnerabilityScannerFacade class.
 */
TEST_F(VulnerabilityScannerFacadeTest, TestStartToEndMethod)
{
    // TODO: Remove GTEST_SKIP and add EXPECTS once the implementation of the 'Indexer Connector' module is completed
    GTEST_SKIP();
    nlohmann::json configuration;

    auto& vulnerabilityScannerFacade {VulnerabilityScannerFacade::instance()};

    EXPECT_NO_THROW(vulnerabilityScannerFacade.start(logFunction, configuration));

    std::this_thread::sleep_for(std::chrono::seconds(DELAY));

    EXPECT_NO_THROW(vulnerabilityScannerFacade.stop());
}
